
package com.sskj.mq.config;

import javax.jms.ConnectionFactory;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jms.annotation.EnableJms;
import org.springframework.jms.config.DefaultJmsListenerContainerFactory;

@Configuration
@EnableJms
public class ActiveMQConfig {

	@Autowired
	ConnectionFactory connectionFactory;

	@Value("${sskj.clientId}")
	private String clientId;

	@Bean(name = { "cmisTjxxListener" })
	public DefaultJmsListenerContainerFactory cmisTjxxListenerContainerFactory4Topic() {

		DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
		factory.setConnectionFactory(connectionFactory);
		factory.setClientId(clientId + "_TJSUMXX");
		factory.setSubscriptionDurable(true);
		return factory;
	}

	/**
	 * 扬尘设备实时数据消息订阅监听
	 * 
	 * @return
	 */
	@Bean(name = { "ycsbsssjListener" })
	public DefaultJmsListenerContainerFactory ycsbsssjListenerContainerFactory4Topic() {

		DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
		factory.setConnectionFactory(connectionFactory);
		factory.setClientId(clientId + "_YCSBSSSJ");
		factory.setSubscriptionDurable(true);
		return factory;
	}

	/**
	 * 扬尘设备预警统计数据消息订阅监听
	 * 
	 * @return
	 */
	@Bean(name = { "ycyjtjListener" })
	public DefaultJmsListenerContainerFactory ycyjtjListenerContainerFactory4Topic() {

		DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
		factory.setConnectionFactory(connectionFactory);
		factory.setClientId(clientId + "_YCYJTJ");
		factory.setSubscriptionDurable(true);
		return factory;
	}

	/**
	 * 扬尘预警消息订阅监听
	 * 
	 * @return
	 */
	@Bean(name = { "ycAlertMessageListener" })
	public DefaultJmsListenerContainerFactory ycAlertMessageListenerContainerFactory4Topic() {

		DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
		factory.setConnectionFactory(connectionFactory);
		factory.setClientId(clientId + "_YCALERTMESSAGE");
		factory.setSubscriptionDurable(true);
		return factory;
	}

	/**
	 * 监督业务提醒消息订阅监听
	 * 
	 * @return
	 */
	@Bean(name = { "ywtxjlListener" })
	public DefaultJmsListenerContainerFactory ywtxjlListenerContainerFactory4Topic() {

		DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
		factory.setConnectionFactory(connectionFactory);
		factory.setClientId(clientId + "_YWTXJL");
		factory.setSubscriptionDurable(true);
		return factory;
	}

}
